package Demo01.Exception;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;

public class Demo04Throws {
    public static void main(String[] args) throws FileNotFoundException,IOException {
        readFile("d:\\a.txt");

    }
    public static void readFile(String fileName) throws FileNotFoundException,IOException{
        if(!fileName.equals("c:\\a.txt")){
            throw new FileNotFoundException("传递的文件路径不是c:\\a.txt");
        }
        if(fileName.equals(".txt")){
            throw new IOException("文件的后缀名不对");
        }
        System.out.println("路径没问题，读取文件");
    }
}


